package cn.iocoder.yudao.module.system.dal.mysql.areaserve;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.system.controller.admin.areaserve.vo.AreaBookingQuotaPageReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.areaserve.AreaBookingQuotaDO;
import org.apache.ibatis.annotations.Mapper;


@Mapper
public interface AreaBookingQuotaMapper  extends BaseMapperX<AreaBookingQuotaDO> {
    default PageResult<AreaBookingQuotaDO> selectPage(AreaBookingQuotaPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<AreaBookingQuotaDO>()
                .eqIfPresent(AreaBookingQuotaDO::getOfficeName, reqVO.getOfficeName())
                .eqIfPresent(AreaBookingQuotaDO::getAreaName, reqVO.getAreaName())
                .ge(AreaBookingQuotaDO::getResourceDate, reqVO.getResourceDate())
                .orderByAsc(AreaBookingQuotaDO::getResourceDate)
                        .last("LIMIT " + String.valueOf(reqVO.getRecentDays()))
                );

    }

}



